/*
* Copyright (C) 2020 ~ 2024 chaigec All Rights Reserved.
*
* Author:     chaigec <chaigec@163.com>
* Maintainer: chaigec <chaigec@163.com>

 * Use of this source code is governed by MIT license that can be found in the
 * LICENSE file in the root of the source tree. All contributing project authors
 * may be found in the AUTHORS file in the root of the source tree.
*/

#include "MkUtil/MkThread.h"
#include "MkUtil/MkMemQueue.h"
#include <gtest/gtest.h>

void*  WaitEvent = nullptr;
TEST(MkThread, ThreadTest)
{
    WaitEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
    CMkThread UtThread;
    UtThread.Start([]() {
		CMkThread::ThreadSleep(100);
        SetEvent(WaitEvent);
    });
    int Ret= WaitForSingleObject(WaitEvent, 0xFFFFFF);
    EXPECT_EQ(WAIT_OBJECT_0, Ret);
    CloseHandle(WaitEvent);
    Uint32 UtThreadId = UtThread.GetCurrentId();
    EXPECT_NE(0, UtThreadId);
    UtThread.Stop();
}